package com.xc.hotelmgr.datahandlermt.controller;

import com.xc.hotelmgr.datahandlermt.pojo.mq.HtlGroupDto;
import com.xc.hotelmgr.datahandlermt.pojo.mq.TaskHotelList;
import com.xc.hotelmgr.datahandlermt.result.MtResult;
import com.xc.hotelmgr.datahandlermt.service.mt.HtInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/ht_info")
@RequiredArgsConstructor
public class HtInfoController {

    private final HtInfoService htInfoService;

    /**
     * 酒店初始化（前端调用），拉取全量酒店ID，放入 hotel_id_list_all 队列
     * @param taskId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "ht_id/{taskId}",method = RequestMethod.GET)
    public MtResult getHtIds(@PathVariable Long taskId) throws Exception {
        htInfoService.getHtId(taskId);
        return new MtResult(0, "成功");
    }

    /**
     * 分组酒店~拉取推送（前端调用），将分组下的酒店ID放入 hotel_id_list 队列
     * @param htlGroupDto
     * @return
     */
    @RequestMapping(value = "ht_group",method = RequestMethod.POST)
    public MtResult getHtlGroup(@RequestBody HtlGroupDto htlGroupDto){
        htInfoService.getHtGroup(htlGroupDto);
        return new MtResult(0, "成功");
    }

    /**
     * consumer-mq 监听hotel_id_list队列调用拉取酒店信息信息（酒店信息、房型信息、RP信息、房态信息）
     * @param taskHotelList
     * @return
     */
    @RequestMapping(value = "ht_detail",method = RequestMethod.POST)
    public MtResult htDetail(@RequestBody TaskHotelList taskHotelList){
        htInfoService.getHtDetail(taskHotelList);
        return new MtResult(0, "成功");
    }

    /**
     * consumer-mq 监听hotel_id_list队列调用拉取酒店信息信息（酒店信息、房型信息、RP信息、房态信息）
     * @param taskHotelList
     * @return
     */
    @RequestMapping(value = "ht_detail_hotel",method = RequestMethod.POST)
    public MtResult htDetailHotel(@RequestBody TaskHotelList taskHotelList){
        htInfoService.getHtInfo(taskHotelList);
        return new MtResult(0, "成功");
    }
    /**
     * consumer-mq 监听hotel_id_list队列调用拉取酒店信息信息（酒店信息、房型信息、RP信息、房态信息）
     * @param taskHotelList
     * @return
     */
    @RequestMapping(value = "ht_detail_room",method = RequestMethod.POST)
    public MtResult htDetailRoom(@RequestBody TaskHotelList taskHotelList){
        htInfoService.getHtRooms(taskHotelList);
        return new MtResult(0, "成功");
    }

    /**
     * consumer-mq 监听hotel_id_list队列调用拉取酒店信息信息（酒店信息、房型信息、RP信息、房态信息）
     * @param taskHotelList
     * @return
     */
    @RequestMapping(value = "ht_detail_goods",method = RequestMethod.POST)
    public MtResult htDetailGoods(@RequestBody TaskHotelList taskHotelList){
        htInfoService.getGoods(taskHotelList);
        return new MtResult(0, "成功");
    }


    /**酒店信息*/
    @RequestMapping(value = "get_ht",method = RequestMethod.POST)
    public MtResult htInfo(@RequestBody TaskHotelList taskHotelList){
        htInfoService.getHtInfo(taskHotelList);
        return new MtResult(0, "成功");
    }

    /**物理房型信息*/
    @RequestMapping(value = "get_roomInfo",method = RequestMethod.POST)
    public MtResult getRooms(@RequestBody TaskHotelList taskHotelList){
        htInfoService.getHtRooms(taskHotelList);
        return new MtResult(0, "成功");
    }

    /**逻辑房型信息以及价格和房态*/
    @RequestMapping(value = "get_goods",method = RequestMethod.POST)
    public MtResult getGoods(@RequestBody TaskHotelList taskHotelList){
        htInfoService.getGoods(taskHotelList);
        return new MtResult(0, "成功");
    }

    /**
     * 从 消息队列 hotel_id_list_all（暂存所有酒店ID），转移消息 到 hotel_id_list（实际拉取队列）队列进行拉取
     * 从前端hotelIdListAll(on_off/{status})可以暂停（移除对 hotel_id_list_all 队列的监听，转移）
     * @param taskHotelList
     * @return
     */
    @RequestMapping(value = "move_htId",method = RequestMethod.POST)
    public MtResult moveHtId(@RequestBody TaskHotelList taskHotelList){
        htInfoService.moveHtId(taskHotelList);
        return new MtResult(0, "成功");
    }

}
